package com.funny.stock.backtest.vo;

import java.math.BigDecimal;

/**
 * @author pengl
 * @date 2020/05/23
 **/
public class TradeInfo {
    private BigDecimal nextSellPrice;

    private BigDecimal nextBuyPrice;

    private BigDecimal curTradePrice;

    private BigDecimal increasePer;

    private BigDecimal decreasePer;


    private boolean isSell;

    public BigDecimal getNextSellPrice() {
        return nextSellPrice;
    }

    public void setNextSellPrice(BigDecimal nextSellPrice) {
        this.nextSellPrice = nextSellPrice;
    }

    public BigDecimal getNextBuyPrice() {
        return nextBuyPrice;
    }

    public void setNextBuyPrice(BigDecimal nextBuyPrice) {
        this.nextBuyPrice = nextBuyPrice;
    }

    public BigDecimal getCurTradePrice() {
        return curTradePrice;
    }

    public void setCurTradePrice(BigDecimal curTradePrice) {
        this.curTradePrice = curTradePrice;
    }

    public boolean isSell() {
        return isSell;
    }

    public void setSell(boolean sell) {
        isSell = sell;
    }

    public BigDecimal getIncreasePer() {
        return increasePer;
    }

    public void setIncreasePer(BigDecimal increasePer) {
        this.increasePer = increasePer;
    }

    public BigDecimal getDecreasePer() {
        return decreasePer;
    }

    public void setDecreasePer(BigDecimal decreasePer) {
        this.decreasePer = decreasePer;
    }

    public static TradeInfo calcNextTradePriceInfo(BigDecimal tradePrice,BigDecimal increasePer,BigDecimal decreasePer){
        BigDecimal nextSellPrice = tradePrice.multiply(increasePer.add(BigDecimal.valueOf(1))).setScale(2,BigDecimal.ROUND_HALF_UP);
        BigDecimal nextBuyPrice = tradePrice.multiply(BigDecimal.valueOf(1).subtract(decreasePer)).setScale(2,BigDecimal.ROUND_HALF_UP);

        TradeInfo info = new TradeInfo();
        info.setNextBuyPrice(nextBuyPrice);
        info.setCurTradePrice(tradePrice);
        info.setNextSellPrice(nextSellPrice);
        info.setDecreasePer(decreasePer);
        info.setIncreasePer(increasePer);

        return info;
    }
}
